﻿namespace hedefgrup.reports.renault.implementation
{
    using hedefgrup.reports.renault;
    using hedefgrup.reports.renault.definitions;
    using System;
    using System.Collections.Generic;

    public class cumulativeData
    {
        public int baseCount;
        public SortedList<string, question> questions = new SortedList<string, question>();
        private dataCache sourceData;

        public cumulativeData(dataCache sourceData)
        {
            this.sourceData = sourceData;
            foreach (questionDefinition definition in this.sourceData.questionDefinitions.Values)
            {
                question question = definition.createQuestion();
                this.questions.Add(question.code, question);
            }
        }

        public void appendCumulativeData(cumulativeData sourceData)
        {
            foreach (questionDefinition definition in this.sourceData.questionDefinitions.Values)
            {
                string str = definition.getCode();
                question question = this.questions[str];
                question.baseCount += sourceData.questions[str].baseCount;
                foreach (int num in definition.optionDefinitions.Keys)
                {
                    question.appendOptionCount(num, sourceData.questions[str].getOptionCount(num));
                }
            }
            this.baseCount += sourceData.baseCount;
        }
    }
}

